/**
	Accounts list. This list is used in accounts management dialogue.
 */
Ext.define('WEB.view.account.List' ,{
    extend: 'Ext.grid.Panel',
    alias : 'widget.accountlist',
	store : 'Accounts',
	viewConfig: {
		emptyText: '<p style="text-align:center;color:#999999;font-weight: '+
			'bold;font-size:120%;margin-top:2em">No accounts found.</p>',
		singleSelect: true,
		allowDeselect: true,
		stripeRows: true
	},
	bodyCls: 'atb-accountlist',
	dockedItems: [{
		xtype: 'toolbar',
       	items: [{
       		icon: 'resources/css/custom/img/icon-add16x16.gif',
            text: 'Add',
            action: 'add'
       	}, {
            icon: 'resources/css/custom/img/icon-edit16x16.png',
            text: 'Update',
            action: 'update',
            disabled: true
        }, {
            icon: 'resources/css/custom/img/icon-delete16x16.png',
            text: 'Delete',
            action: 'delete',
            disabled: true
        }]
    }],

    initComponent: function() {
        this.columns = [
            {header: 'Account Name', dataIndex: 'lastName', flex: 1, renderer: renderAccountRow}
        ];
		
        this.callParent(arguments);
    }
});

/*
	Custom renderer for a row in accounts list.
*/
function renderAccountRow(value, p, record) {
	return Ext.String.format('<div style="cursor:pointer">'+
		'<div style="font-weight:bold;font-size:130%">{0}'+
		'<div style="color:#777777;float:right;font-weight:normal;font-size:80%">'+
		'{3}&nbsp;|&nbsp;{2}</div></div>'+
		'<div style="color:#777777;font-style:italic;font-family:Georgia,Serif;'+
		'white-space:normal;">{1}</div>'+
		'</div>',
		value,record.data.firstName,record.data.address,record.data.email);
}
